package com.boboPlanet.comm.rabbitmq;

import com.boboPlanet.comm.rabbitmq.producer.IMqBuild;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Description: TODO 星球 MQ 公共bean配置枚举
 * @Author: mis_wu
 * @Date: 2023/6/27
 **/
@AllArgsConstructor
@Getter
public enum PlanetCommMQEnum implements IMqBuild {
    /**
     * 构建一个空的 MQ，后面提供其他sendMsg赋值
     */
    EMPTY_MQ("","","","",null),

    /**
     * 星球错误MQ，当MQ发送失败时,到达最大重试次数，消息推送至定义的错误交换机
     */
    PLANET_ERROR_MQ("planet.error.queue","planet.error.direct","","planet.error",null),

    PLANET_SAVE_FILE_MQ("planet.saveFile.queue","planet.saveFile.topic","","planet.saveFile",false),
    ;



    private String queue;

    private String exchange;

    private String exchangeType;

    private String routingKey;

    /**
     * 发送MQ时是否需要授权,默认true
     */
    private Boolean isAuth;

    public void build(String queue,String exchange,String exchangeType,String routingKey,Boolean isAuth){
        EMPTY_MQ.queue = queue;
        EMPTY_MQ.exchange = exchange;
        EMPTY_MQ.exchangeType = exchangeType;
        EMPTY_MQ.routingKey = routingKey;
        if (isAuth == null){
            isAuth = true;
        }
        EMPTY_MQ.isAuth = isAuth;
    }

    @Override
    public String queue() {
        return this.queue;
    }

    @Override
    public String exchange() {
        return this.exchange;
    }

    @Override
    public String exchangeType() {
        return this.exchangeType;
    }

    @Override
    public String routingKey() {
        return this.routingKey;
    }

    @Override
    public Boolean isAuth() {
        return this.isAuth;
    }
}
